package com.wswy.wzcx.model.topic

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import java.util.*

/**
 * 主题
 */

class TopicModel (
        @SerializedName("id") val id:Long=0,
        @SerializedName("userId")val userId:String?,
        @SerializedName("content")val content:String?=null,
        @SerializedName("topic")val topicTag:String?=null,
        @SerializedName("images") val images:Array<String>?=null,
        @SerializedName("createTime")val createTime:Long=0,
        @SerializedName("commentNumber")val commentNumber:Int=0,
        @SerializedName("statNumber")val statNumber:Int=0,
        @SerializedName("whetherStar")val whetherStar:Boolean=false,
        @SerializedName("username")val userName:String?=null,
        @SerializedName("avatar")val avatar:String?=null

) :Parcelable{
    constructor(parcel: Parcel) : this(
            parcel.readLong(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.createStringArray(),
            parcel.readLong(),
            parcel.readInt(),
            parcel.readInt(),
            parcel.readByte() != 0.toByte(),
            parcel.readString(),
            parcel.readString()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(id)
        parcel.writeString(userId)
        parcel.writeString(content)
        parcel.writeString(topicTag)
        parcel.writeStringArray(images)
        parcel.writeLong(createTime)
        parcel.writeInt(commentNumber)
        parcel.writeInt(statNumber)
        parcel.writeByte(if (whetherStar) 1 else 0)
        parcel.writeString(userName)
        parcel.writeString(avatar)
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as TopicModel

        if (id != other.id) return false
        if (userId != other.userId) return false

        return true
    }


    companion object CREATOR : Parcelable.Creator<TopicModel> {
        override fun createFromParcel(parcel: Parcel): TopicModel {
            return TopicModel(parcel)
        }

        override fun newArray(size: Int): Array<TopicModel?> {
            return arrayOfNulls(size)
        }
    }




}